<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加排班</title>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/style1.css" rel="stylesheet">
    <link href="/css/style.css" rel="stylesheet">
</head>
<body>
<div th:insert="~{admin/header1}"></div>
<main id="main" style="margin-top: 100px">
    <section class="breadcrumbs">
        <div class="container">
            <div class="d-flex justify-content-between align-items-center">
                <ol>
                    <li><a href="#">首页</a></li>
                    <li><a href="#">添加排班</a></li>
                </ol>
            </div>
        </div>
    </section>
    <section class="inner-page">
        <div class="container">
            <div class="card ">
                <div class="card-header">
                    <h3  class="card-title">添加排班</h3>
                    <div class="card-body text-center">
                    <form th:action="@{/plans}" th:object="${plan}" method="post">
                        <input type="hidden" id="doctorId" th:field="*{doctorId}" required>
                        <span for="doctorSelect">医生姓名:</span>
                        <select id="doctorSelect" required onchange="setDoctorId(this)">
                            <option value="">请选择医生</option>
                            <option th:each="doctor : ${doctorList}" th:value="${doctor.id}" th:text="${doctor.name}"></option>
                        </select>
                        <span for="num">看诊人数:</span>
                        <input type="text" id="num" th:field="*{num}" required>
                        <span for="weekday">工作时间:</span>
                        <select id="weekday" th:field="*{weekday}" required>
                            <option value="">请选择</option>
                            <option value="Monday">星期一</option>
                            <option value="Tuesday">星期二</option>
                            <option value="Wednesday">星期三</option>
                            <option value="Thursday">星期四</option>
                            <option value="Friday">星期五</option>
                            <option value="Saturday">星期六</option>
                            <option value="Sunday">星期日</option>
                        </select>
                        <div class="text-center">
                        <button type="submit">保存</button>
                        </div>
                    </form>
                        <span th:text="${msg}" style="display:none;" id="errorMsg"></span>
                </div>
                </div>
            </div>
        </div>
    </section>
</main>
<script>
    function setDoctorId(selectElement) {
        // 获取选中的医生ID
        var doctorId = selectElement.value;
        // 设置隐藏的医生ID输入框的值
        document.getElementById('doctorId').value = doctorId;
    }
    window.onload = function() {
        var errorMessage = document.getElementById('errorMsg').textContent;
        if (errorMessage) {
            alert(errorMessage);
        }
    };
</script>
</body>
</html>